Skip to content

Added labels support for ci-secret-bootstrap#5189

Open
hector-vido wants to merge 1 commit into
openshift:mainfrom
hector-vido:labels-support-secret-bootstrap
Open

Added labels support for ci-secret-bootstrap#5189
hector-vido wants to merge 1 commit into
openshift:mainfrom
hector-vido:labels-support-secret-bootstrap

Conversation

@hector-vido
Copy link
Copy Markdown
Contributor

@hector-vido hector-vido commented May 19, 2026

Since we are using ci-secret-bootstrap to manage ArgoCD cluster secrets we need a way specify labels inside the secret stored on vault to avoid manual work.

ArgoCD identify cluster secrets based on the label argocd.argoproj.io/secret-type: cluster added to the secrets that maps a ServiceAccount and a token from other clusters inside openshift-gitops.

This PR add this possibility.

Labels support for ci-secret-bootstrap

This PR enables ci-secret-bootstrap to apply Kubernetes labels to Secrets it syncs from Vault so operators can manage label-dependent workflows (notably ArgoCD cluster-secret discovery) automatically.

What changed (practical impact)

  • ci-secret-bootstrap (cmd/ci-secret-bootstrap)

    • Recognizes a new Vault metadata key (pkg/api/vault.SecretSyncTargetLabelsKey = "secretsync/target-labels") that contains comma-separated "key: value" label pairs.
    • Parses, trims and validates label keys and values against Kubernetes label rules; invalid entries are skipped and logged.
    • Merges validated labels with the existing ci-secret-bootstrap requester label and writes them to Secret.ObjectMeta.Labels when creating or updating Secrets.
    • Treats the secretsync/target-labels Vault key as reserved metadata so it is not stored in Secret.Data.
    • When deciding whether to update an existing Secret, compares desired vs existing ObjectMeta.Labels in addition to Secret.Data and performs in-place updates when labels differ, honoring the existing requester-label guard.
  • vault-subpath-proxy (cmd/vault-subpath-proxy)

    • KV update request validation now treats the new secretsync/target-labels key as metadata (like secretsync/target-clusters) so it bypasses normal secret-key regex validation and is accepted as a metadata field.

Why this matters for CI operators

  • Operators can store desired Kubernetes labels in Vault and have ci-secret-bootstrap apply them during sync. This eliminates manual post-sync labeling for workflows that depend on labels (for example adding argocd.argoproj.io/secret-type: cluster so ArgoCD discovers cluster secrets automatically).

Technical notes

  • New exported constant: pkg/api/vault.SecretSyncTargetLabelsKey = "secretsync/target-labels".
  • No public function signatures changed; go.mod dependency versions were updated as part of the commit.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Vault-driven secret labels: a new exported Vault key, proxy validation skip for that key, parsing/validation and application of labels in ci-secret-bootstrap (including reserved-key handling), and update-on-label-drift for managed Secrets. go.mod dependency versions are also updated.

Changes

Secret sync target labels support

Layer / File(s) Summary
Define secret sync target labels key
pkg/api/vault/vault.go
New exported constant SecretSyncTargetLabelsKey defines the Vault key secretsync/target-labels for label data.
Skip labels key in Vault request validation
cmd/vault-subpath-proxy/kv_update_transport.go
Validation loop now treats SecretSyncTargetLabelsKey as a reserved sync key, bypassing regex checks alongside the cluster target key.
Parse and apply sync labels from Vault
cmd/ci-secret-bootstrap/main.go
fetchUserSecrets imports label validators, parses comma-separated validated key: value pairs from Vault, excludes the reserved sync key from Secret Data, and sets ObjectMeta.Labels on new and existing Secrets.
Detect and apply label changes
cmd/ci-secret-bootstrap/main.go
updateSecrets computes deep-equality of desired vs existing Secret labels and includes label drift in the in-place update condition for Secrets managed by ci-secret-bootstrap.
Tooling and deps
go.mod
Updates multiple direct and indirect module versions and a replace directive; Go toolchain version unchanged.
Tests: use cmp.Diff
pkg/lease/client_test.go
Replace diff.ObjectDiff with cmp.Diff in mismatch output and remove the old import.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Go Error Handling ⚠️ Warning In cmd/ci-secret-bootstrap/main.go, label parsing code accesses label[1] without bounds checking. strings.Split without colons returns <2 elements, causing panic. Add len(label) >= 2 check before accessing label[1]; otherwise skip/warn the malformed label.
Test Coverage For New Features ⚠️ Warning Label parsing and validation in fetchUserSecrets lack test coverage. No test cases verify label syncing functionality. Add test cases for label parsing, validation, trimming, rejection of invalid labels, and label-based secret updates.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main feature added: labels support for ci-secret-bootstrap, which aligns with the core changes in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed This PR does not use Ginkgo testing framework. All test files use standard Go testing package with table-driven tests. Test names are static and descriptive. Check is not applicable.
Test Structure And Quality ✅ Passed PR does not add/modify Ginkgo tests. Repository uses standard Go testing (testing.T), not Ginkgo. Custom check is inapplicable.
Microshift Test Compatibility ✅ Passed This PR does not add any new Ginkgo e2e tests. It modifies existing code and unit test assertions. The custom check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR adds no Ginkgo e2e tests. Changes are to internal tooling, constants, dependencies, and unit tests only. SNO compatibility check does not apply.
Topology-Aware Scheduling Compatibility ✅ Passed PR does not add deployment manifests, operators, or controllers. Changes are to CLI tools that manipulate Kubernetes secrets' labels and dependencies. No scheduling constraints are introduced.
Ote Binary Stdout Contract ✅ Passed No stdout violations detected. Changes are pure logic modifications for label handling. Logging continues to use logrus (stderr). No os.Stdout, io.Stdout, or fmt.Print* calls added.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests are added in this PR. The changes are production code and unit test assertions. The check is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from danilo-gemoli and smg247 May 19, 2026 00:29
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 19, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hector-vido

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 19, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/ci-secret-bootstrap/main.go`:
- Around line 674-680: User-provided labels parsed from
secretKeys[vaultapi.SecretSyncTargetLabelsKey] can overwrite the seeded
controller label api.DPTPRequesterLabel in the labels map; update the parsing
logic (the block that builds labels from vaultValue in
cmd/ci-secret-bootstrap/main.go) to reject or ignore any entry whose key equals
api.DPTPRequesterLabel so the initially-seeded labels map entry is never
replaced (ensure the same behavior is enforced before updateSecrets is called).
- Around line 675-680: The current Vault label parsing loop can panic on
malformed entries; update the block that handles
secretKeys[vaultapi.SecretSyncTargetLabelsKey] (variables vaultValue and labels)
to robustly parse each label: use strings.SplitN(entry, ":", 2),
strings.TrimSpace on both key and value, validate that you got exactly 2
non-empty parts, and either skip invalid entries or return a contextual error
(with which entry failed) instead of letting label[1] panic; ensure the final
parsed key/value are stored into labels only after trimming and validation.

In `@cmd/vault-subpath-proxy/kv_update_transport.go`:
- Around line 125-126: The branch only updated the regex but you must treat
SecretSyncTargetLabelsKey as a reserved key throughout this transport: update
validateKeysDontConflict to ignore vault.SecretSyncTargetLabelsKey when checking
for claimed keys, change syncSecret so it does not include
vault.SecretSyncTargetLabelsKey in Secret.Data or write it as normal secret
data, and update any cache builder routines that enumerate keys (e.g., functions
building the local cache or mapping keys to clusters) to skip
vault.SecretSyncTargetLabelsKey so it is never persisted or compared in conflict
checks; keep the same logic/guard used for vault.SecretSyncTargetClusterKey for
consistency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 1b2b4634-8cfc-4261-99af-ce14c9e57856

📥 Commits

Reviewing files that changed from the base of the PR and between e3ac258 and f93da75.

📒 Files selected for processing (3)
  • cmd/ci-secret-bootstrap/main.go
  • cmd/vault-subpath-proxy/kv_update_transport.go
  • pkg/api/vault/vault.go

Comment thread cmd/ci-secret-bootstrap/main.go
Comment thread cmd/ci-secret-bootstrap/main.go
Comment thread cmd/vault-subpath-proxy/kv_update_transport.go Outdated
@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch from f93da75 to ff9898d Compare May 19, 2026 13:53
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@go.mod`:
- Line 5: The go.mod replace directive downgrades github.com/docker/distribution
to v2.7.1, reintroducing known vulnerabilities; remove or update that replace
entry so the project uses v2.8.3 or newer (i.e., delete or change the line
"replace github.com/docker/distribution => github.com/docker/distribution
v2.7.1+incompatible" to omit the replace or point to v2.8.3+incompatible), then
run go mod tidy to ensure module graph is refreshed and the secure version is
used.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 92bacdb6-52c2-4727-b315-c5086234b321

📥 Commits

Reviewing files that changed from the base of the PR and between f93da75 and ff9898d.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum, !go.sum
📒 Files selected for processing (4)
  • cmd/ci-secret-bootstrap/main.go
  • cmd/vault-subpath-proxy/kv_update_transport.go
  • go.mod
  • pkg/api/vault/vault.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/api/vault/vault.go
  • cmd/vault-subpath-proxy/kv_update_transport.go
  • cmd/ci-secret-bootstrap/main.go

Comment thread go.mod
@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch from ff9898d to 05c4a78 Compare May 19, 2026 14:57
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@go.mod`:
- Line 157: Update the pinned indirect dependency k8s.io/kubernetes in go.mod to
a patched 1.29.x release (at least v1.29.7) to eliminate CVE-2024-10220 and
CVE-2024-5321; open go.mod, replace the existing k8s.io/kubernetes v1.29.2 entry
with v1.29.7 (or later) and run go get k8s.io/kubernetes@v1.29.7 followed by go
mod tidy to update the lock file, or if the package is unnecessary remove the
k8s.io/kubernetes line and run go mod tidy to prune it from the module graph.
- Line 59: The go.mod currently pins k8s.io/apimachinery to v0.35.5 while other
Kubernetes modules (k8s.io/api, k8s.io/apiserver, k8s.io/client-go) remain at
v0.32.8 causing API/type/protobuf skew; update the Kubernetes module versions so
their minor versions match (e.g., set k8s.io/apimachinery to v0.32.x to match
k8s.io/api, k8s.io/apiserver, k8s.io/client-go or bump all peers to the same
v0.35.x), then run go get / go mod tidy to resolve transitive deps and ensure
builds pass — target the same minor for k8s.io/apimachinery, k8s.io/api,
k8s.io/apiserver, and k8s.io/client-go.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: c20093fc-2c29-482d-a2d6-827116a19025

📥 Commits

Reviewing files that changed from the base of the PR and between ff9898d and 05c4a78.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum, !go.sum
📒 Files selected for processing (4)
  • cmd/ci-secret-bootstrap/main.go
  • cmd/vault-subpath-proxy/kv_update_transport.go
  • go.mod
  • pkg/api/vault/vault.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • cmd/vault-subpath-proxy/kv_update_transport.go
  • pkg/api/vault/vault.go
  • cmd/ci-secret-bootstrap/main.go

Comment thread go.mod Outdated
Comment thread go.mod
@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch 2 times, most recently from bea027f to 4bba3a9 Compare May 19, 2026 15:18
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
go.mod (2)

5-5: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Remove the docker/distribution downgrade to v2.7.1 — it reintroduces known security vulnerabilities.

This issue was previously flagged and remains unresolved. The replace directive downgrades from v2.8.3 to v2.7.1, reintroducing HIGH severity vulnerabilities including OOM via malicious catalog API input and OCI manifest type confusion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@go.mod` at line 5, The go.mod contains a replace directive "replace
github.com/docker/distribution => github.com/docker/distribution
v2.7.1+incompatible" which downgrades to a vulnerable version; remove or update
that replace so the module uses a secure version (e.g., v2.8.3 or later) instead
of v2.7.1+incompatible: edit the go.mod to delete or change the replace line
referencing github.com/docker/distribution and run go mod tidy to ensure
dependencies are resolved to the non-vulnerable release.

157-157: ⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

Pin k8s.io/kubernetes to a patched version to resolve HIGH severity vulnerabilities.

This issue was previously flagged and remains unresolved. Version 1.29.2 contains multiple HIGH severity vulnerabilities including CVE-2024-10220 (kubelet arbitrary command execution) and CVE-2024-5321 (incorrect Windows container log permissions). Upgrade to v1.29.7 or later in the 1.29.x series.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@go.mod` at line 157, Update the k8s.io/kubernetes module pin in go.mod
(currently "k8s.io/kubernetes v1.29.2") to a patched 1.29.x release (e.g.,
v1.29.7 or later) to address the reported HIGH severity CVEs, then run the Go
tooling to apply and verify the change (e.g., `go get
k8s.io/kubernetes@v1.29.7`, followed by `go mod tidy` and `go test`/build) so
go.sum is updated and the project still compiles/tests pass.
🧹 Nitpick comments (1)
go.mod (1)

191-191: ⚡ Quick win

Consider investigating the reason for pinning k8s.io/metrics to v0.32.0.

k8s.io/metrics is at v0.32.0 while core modules (k8s.io/api, k8s.io/apimachinery, k8s.io/apiserver, k8s.io/client-go) are at v0.35.5. The codebase uses it only in pkg/metrics/ (3 files) and there are no observed build or type compatibility issues. This version is likely pinned to satisfy a transitive dependency requirement (e.g., from sigs.k8s.io/prow). Verify whether aligning versions is safe or if the lower version is intentional for compatibility.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@go.mod` at line 191, The go.mod pins k8s.io/metrics to v0.32.0 while core k8s
modules are v0.35.5; inspect whether this downgrade is required by a transitive
dependency and if it's safe to align to v0.35.5. In the repo, check usage in
pkg/metrics/* and run go list -m all / go mod graph to find which module
requires v0.32.0 (e.g., sigs.k8s.io/prow), attempt to update by running go get
k8s.io/metrics@v0.35.5 and go mod tidy, then build and run tests to confirm no
type/API breakage; if a transitive consumer prevents the bump, document that
dependency and keep the pin.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@go.mod`:
- Line 5: The go.mod contains a replace directive "replace
github.com/docker/distribution => github.com/docker/distribution
v2.7.1+incompatible" which downgrades to a vulnerable version; remove or update
that replace so the module uses a secure version (e.g., v2.8.3 or later) instead
of v2.7.1+incompatible: edit the go.mod to delete or change the replace line
referencing github.com/docker/distribution and run go mod tidy to ensure
dependencies are resolved to the non-vulnerable release.
- Line 157: Update the k8s.io/kubernetes module pin in go.mod (currently
"k8s.io/kubernetes v1.29.2") to a patched 1.29.x release (e.g., v1.29.7 or
later) to address the reported HIGH severity CVEs, then run the Go tooling to
apply and verify the change (e.g., `go get k8s.io/kubernetes@v1.29.7`, followed
by `go mod tidy` and `go test`/build) so go.sum is updated and the project still
compiles/tests pass.

---

Nitpick comments:
In `@go.mod`:
- Line 191: The go.mod pins k8s.io/metrics to v0.32.0 while core k8s modules are
v0.35.5; inspect whether this downgrade is required by a transitive dependency
and if it's safe to align to v0.35.5. In the repo, check usage in pkg/metrics/*
and run go list -m all / go mod graph to find which module requires v0.32.0
(e.g., sigs.k8s.io/prow), attempt to update by running go get
k8s.io/metrics@v0.35.5 and go mod tidy, then build and run tests to confirm no
type/API breakage; if a transitive consumer prevents the bump, document that
dependency and keep the pin.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 76b6c04c-57c4-48f8-a89c-827a3173069b

📥 Commits

Reviewing files that changed from the base of the PR and between bea027f and 4bba3a9.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum, !go.sum
📒 Files selected for processing (5)
  • cmd/ci-secret-bootstrap/main.go
  • cmd/vault-subpath-proxy/kv_update_transport.go
  • go.mod
  • pkg/api/vault/vault.go
  • pkg/lease/client_test.go
✅ Files skipped from review due to trivial changes (1)
  • pkg/api/vault/vault.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/vault-subpath-proxy/kv_update_transport.go
  • cmd/ci-secret-bootstrap/main.go

@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch 2 times, most recently from f18c83b to 76c88d8 Compare May 19, 2026 16:11
@hector-vido
Copy link
Copy Markdown
Contributor Author

/test lint unit

@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch 2 times, most recently from 6449a1f to f601659 Compare May 20, 2026 01:47
@hector-vido
Copy link
Copy Markdown
Contributor Author

/retest

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e

@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch from f601659 to 9100afd Compare May 20, 2026 13:36
Comment thread cmd/ci-secret-bootstrap/main_test.go Outdated
@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch from 9100afd to 33c0d2c Compare May 20, 2026 14:04
Comment thread cmd/ci-secret-bootstrap/main.go Outdated
Comment thread cmd/ci-secret-bootstrap/main.go
Comment thread cmd/ci-secret-bootstrap/main.go Outdated
Comment thread cmd/ci-secret-bootstrap/main.go Outdated
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e

@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch from 33c0d2c to c7c607c Compare May 20, 2026 16:16
@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch from c7c607c to fc4e9a1 Compare May 20, 2026 17:28
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e

@hector-vido
Copy link
Copy Markdown
Contributor Author

/test e2e

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

2 similar comments
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

continue
}
if key == vault.SecretSyncTargetLabelsKey {
if len(strings.TrimSpace(value)) == 0 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are mutating the real value here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens during the put/patch, I am mutating, indeed, but this is the only way to check if this value is not empty or some blank string.
Why is this method a problem?

Comment thread cmd/ci-secret-bootstrap/main.go Outdated
entry, alreadyExists := secretsMap[cluster][secretName]
labels := map[string]string{api.DPTPRequesterLabel: "ci-secret-bootstrap"}
if vaultValue, ok := secretKeys[vaultapi.SecretSyncTargetLabelsKey]; ok {
if vaultValue != "" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already now validated, and also you don't want to check that.. If the value is empty, then we go with the empty value and fail in the next validation either way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will avoid testing if the value is empty during secrets synchronization, but when this "next validation" will happen? Are you talking about IsQualifiedName and IsValidLabelValue?

Comment thread cmd/ci-secret-bootstrap/main.go Outdated
labels := map[string]string{api.DPTPRequesterLabel: "ci-secret-bootstrap"}
if vaultValue, ok := secretKeys[vaultapi.SecretSyncTargetLabelsKey]; ok {
if vaultValue != "" {
for _, label := range strings.Split(vaultValue, ",") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this logic out of here. Put it on its own function, or even better a method of the secretKeys if its easy to refactor. Either way, you need to have a separate unittests for that logic as well.

Comment thread cmd/ci-secret-bootstrap/main.go Outdated
Comment thread cmd/ci-secret-bootstrap/main.go Outdated
Data: map[string][]byte{},
Type: coreapi.SecretTypeOpaque,
}
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you do inside this else is not related to what you are checking on if. Also, the existance check has to do with the objectMeta namespace and name, since we will get the existing secret. Either way, you will override the labels in the end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see a relation, if the secret exists I just overwrite the labels because someone could changed it for another value.

Should I just overwrite it, declaring an ObjectMeta without labels and after the if define it?

if !alreadyExists {
    entry = coreapi.Secret{
        ObjectMeta: metav1.ObjectMeta{
            Namespace: secretName.Namespace,
            Name:      secretName.Name,
        },
        Data: map[string][]byte{},
        Type: coreapi.SecretTypeOpaque,
    }
}
entry.ObjectMeta.Labels = labels

}
for vaultKey, vaultValue := range secretKeys {
if vaultKey == vaultapi.SecretSyncTargetClusterKey {
if vaultKey == vaultapi.SecretSyncTargetClusterKey || vaultKey == vaultapi.SecretSyncTargetLabelsKey {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you changed that. Can you elaborate?

Copy link
Copy Markdown
Contributor Author

@hector-vido hector-vido May 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this key is not used to create an entry inside the data secret stanza, we need to skip it the same way we skip the target cluster vault data.

Comment thread cmd/ci-secret-bootstrap/main_test.go
@hector-vido hector-vido force-pushed the labels-support-secret-bootstrap branch from fc4e9a1 to fd40304 Compare May 21, 2026 21:45
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 21, 2026

@hector-vido: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants